package com.xuz.factory.abstract_factory;

import com.xuz.factory.abstract_factory.factory.AppliancesFactory;
import com.xuz.factory.abstract_factory.factory.HisenseFactory;
import com.xuz.factory.abstract_factory.product.AbstractFreezer;
import com.xuz.factory.abstract_factory.product.AbstractTV;
import lombok.Data;

/**
 * 客户端
 * @user 65453
 * @date 2024/9/25 22:34
 */
@Data
public class Client {

    private AbstractTV tv;

    private AbstractFreezer freezer;

    public Client(AppliancesFactory factory) {
        // 在客户端看来就是使用抽象工厂来生产家电
        this.tv = factory.createTV();
        this.freezer = factory.createFreezer();
    }

    public static void main(String[] args) {
        Client client = new Client(new HisenseFactory());
        AbstractTV tv = client.getTv();
        System.out.println(tv);

        AbstractFreezer freezer = client.getFreezer();
        System.out.println(freezer);
    }
}
